package com.jinzhi.jzweb.controller;


import com.baomidou.mybatisplus.plugins.Page;
import com.jinzhi.common.annotation.Log;
import com.jinzhi.common.base.BaseController;
import com.jinzhi.common.utils.Result;
import com.jinzhi.jzweb.pojo.LldrawlotsVO;
import com.jinzhi.jzweb.pojo.ScdrawlotsVO;
import com.jinzhi.jzweb.service.TrackDrawYuLinService;
import com.jinzhi.jzweb.utils.EasyPoiUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 
 * <pre>
 * 赛道抽签表（存储抽签信息）
 * </pre>
 * <small> 2024-02-28 09:32:18 | lance</small>
 */
@Controller
@RequestMapping("/jzweb/trackDrawYuLin")
public class TrackDrawYuLinController extends BaseController {

    @Autowired
    private TrackDrawYuLinService trackDrawYuLinService;


    /**
     * 理论抽签接口--原始的抽签接口  想要更换原始的抽签接口要把接口名后的数字去掉
     * @return
     */
    @ResponseBody
    @GetMapping("/drawlots1")
    public Result<Integer> drawlots1(){
        return Result.ok(trackDrawYuLinService.trackDrawList());
    }

    /**
     * 理论抽签接口--广州
     * @return
     */
    @ResponseBody
    @GetMapping("/drawlots")
    public Result<Integer> drawlots(){
        return Result.ok(trackDrawYuLinService.trackDrawListGuangZhou());
    }

    /**
     * 查询理论抽签结果
     */
    @ResponseBody
    @GetMapping("/trackList")
    public Result<Page<LldrawlotsVO>> trackList(int current, int number){
        return Result.ok(trackDrawYuLinService.trackList(current, number));
    }




    /**
     * 实操抽签接口
     * @return
     */
    @ResponseBody
    @GetMapping("/scdrawlots")
    public Result<Integer> scdrawlots(){
        return Result.ok(trackDrawYuLinService.sctrackDrawList());
    }

    /**
     * 实操抽签结果
     */
    @ResponseBody
    @GetMapping("/sctrackList")
    public Result<Page<ScdrawlotsVO>> sctrackList(int current, int number){
        return Result.ok(trackDrawYuLinService.sctrackList(current, number));
    }




    /**
     * 理论导出抽签结果信息
     *
     * @param response
     */
    @Log("导出抽签结果信息")
    @RequestMapping("/downloadImportTemplate")
    @ResponseBody
    public void downloadImportTemplate(HttpServletResponse response) {
        Page<LldrawlotsVO>  lldrawlotsVOPage =  trackDrawYuLinService.trackList(1, 9999);
        List<LldrawlotsVO> records = lldrawlotsVOPage.getRecords();
        EasyPoiUtil.exportExcel(records, "理论赛场抽签导出", "理论赛场抽签导出", LldrawlotsVO.class,  "理论赛场抽签导出", response);
    }


    /**
     * 实操导出抽签结果信息
     *
     * @param response
     */
    @Log("导出抽签结果信息")
    @RequestMapping("/scDownloadImportTemplate")
    @ResponseBody
    public void scDownloadImportTemplate(HttpServletResponse response) {
        Page<ScdrawlotsVO> lldrawlotsVOPage =  trackDrawYuLinService.sctrackList(1, 9999);
        List<ScdrawlotsVO> records = lldrawlotsVOPage.getRecords();
        EasyPoiUtil.exportExcel(records, "实操赛场抽签导出", "实操赛场抽签导出", ScdrawlotsVO.class,  "实操赛场抽签导出", response);
    }

	
}
